gh-150663: Document that PyErr_SetRaisedException() accepts NULL#150705
Open
philthompson10 wants to merge 4 commits into
Open
gh-150663: Document that PyErr_SetRaisedException() accepts NULL#150705philthompson10 wants to merge 4 commits into
PyErr_SetRaisedException() accepts NULL#150705philthompson10 wants to merge 4 commits into
Conversation
Documented that `PyErr_SetRaisedException()` accepts `NULL` as the value of the exception being set.
Documentation build overview
31 files changed ·
|
| .. warning:: | ||
|
|
||
| This call steals a reference to *exc*, which must be a valid exception. | ||
| *exc* must be a valid exception (in which case a reference is stolen) or |
Member
There was a problem hiding this comment.
The fact that it can be NULL should not be in a warning.
Removed the warning and expanded the main part of the explanation.
Comment on lines
+501
to
+502
| A stolen reference to *exc* is set as the exception currently being raised, | ||
| clearing the existing exception if one is set. *exc* may be ``NULL`` in |
Member
There was a problem hiding this comment.
Keep the warning, but only use it for the note about reference stealing. The sentence about exc being NULL should go in the body.
Member
There was a problem hiding this comment.
I think that it is better to use note instead of warning, like in PyList_SetItem and many other functions that steal references.
I suggest to add "If exc is NULL, just clear the existing exception." to the body and replace warning with note.
Author
|
On 03/06/2026 13:17, Peter Bierma wrote:
@ZeroIntensity commented on this pull request.
> + A stolen reference to *exc* is set as the exception currently
> being raised,
+ clearing the existing exception if one is set. *exc* may be
``NULL`` in
Keep the warning, but only use it for the note about reference
stealing. The sentence about `exc` being `NULL` should go in the body.
No other call in this section uses warnings for this information.
Specifically `PyErr_Restore()` includes it in the body.
|
Member
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documented that
PyErr_SetRaisedException()acceptsNULLas the value of the exception being set.PyErr_SetRaisedException()accepts NULL #150663